﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XNAchievement;

namespace AchievementTestGame
{
    //This is a custom Notification Handler as you will propably implement it.
    //This Handler shows a PopUp from the GSMS, in your game you will have a
    //custom ui ;)
    class PopUpNotificationHandler : INotificationHandler
    {
        private ScreenManager screenManager;

        public PopUpNotificationHandler(ScreenManager mananager)
        {
            screenManager = mananager;
        }
        
        #region INotificationHandler Member

        public void HandleAnyNotification(object sender, AnyNotificationEventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Notification");
            switch (e.NotificationType)
            {
                case NotificationType.Unlocked:
                    sb.AppendFormat("{0} Unlocked!{1}{2}", e.Achievement.Name, Environment.NewLine, e.Achievement.Description);
                    break;
                case NotificationType.Progressed:
                    sb.AppendFormat("{0} Progressed to {1:##%}!", e.Achievement.Name, (float)e.UserData);
                    break;
                case NotificationType.Special:
                    sb.AppendFormat("{0}: Special event!", e.Achievement.Name);
                    break;
            }

            screenManager.AddScreen(new MessageBoxScreen(sb.ToString(), false), null);
        }

        #endregion
    }
}
